package com.example.demo.mapper;

import com.example.demo.mapper.entity.Avatar;
import com.example.demo.mapper.entity.Clothing;
import com.example.demo.mapper.entity.StudentClothing;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Lucy
 * @create 2024-02-19 21:08
 */
@Mapper
@Repository
public interface StudentClothingMapper {
    @Select("SELECT * FROM clothing WHERE clothing_id = #{clothingId}")
    Clothing selectClothingById(int clothingId);
    @Insert("INSERT INTO student_clothing (student_id, clothing_id) " +
            "VALUES (#{studentId}, #{clothingId})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insertStudentClothing(StudentClothing studentClothing);
    @Select("SELECT * FROM student_clothing WHERE student_id = #{studentId}")
    List<StudentClothing> selectStudentClothing(int studentId);
    @Select("SELECT * FROM avatar WHERE student_id = #{studentId}")
    List<Avatar> selectAvatarListByStudentId(int studentId);
    @Delete("DELETE FROM avatar WHERE student_id = #{studentId}")
    void deleteAvatarListByStudentId(int studentId);
    @Insert("INSERT INTO avatar (student_id, clothing_id, image_url, clothing_type) " +
            "VALUES (#{studentId}, #{clothingId}, #{imageUrl}, #{clothingType})")
    @Options(useGeneratedKeys = true, keyProperty = "avatarId", keyColumn = "avatar_id")
    void insertAvatar(Avatar avatar);
}
